/*
 * sync.h
 *
 *  Created on: Jun 16, 2012
 *      Author: bysse
 */

#ifndef SYNC_H_
#define SYNC_H_

#include <time.h>
#include <map>

#define NANOTIME 1000000000

#define SYNC_RANDOM		0xfc
#define SYNC_SINE_FAST	0xfe
#define SYNC_SINE		0xff

class Sync {
public:
	Sync();
	~Sync();

	void channel(const int id, float value);
	float channel(const int id);

	float operator [](const int id) {
		return channel(id);
	}

	void timeStart();
	float framestart();
	float time();
	float fps();

private:
	long int ticks();

	long int t0;
	long int lastframe;
	float adjustedTime;
	float adjustedFps;

	std::map<int, float> channels;
};

#endif /* SYNC_H_ */
